{% extends 'warehouse/base.html' %}

{% block title %}创建盘点记录{% endblock %}

{% block content %}
<div class="row">
    <div class="col-md-12">
        <h1>创建盘点记录</h1>
        
        {% if messages %}
            {% for message in messages %}
                <div class="alert alert-{{ message.tags }} alert-dismissible fade show" role="alert">
                    {{ message }}
                    <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
                </div>
            {% endfor %}
        {% endif %}
        
        <div class="card">
            <div class="card-header">
                <h3>盘点信息</h3>
            </div>
            <div class="card-body">
                <form method="post">
                    {% csrf_token %}
                    <div class="mb-3">
                        <label for="{{ form.goods.id_for_label }}" class="form-label">{{ form.goods.label }}</label>
                        {{ form.goods }}
                        {% if form.goods.help_text %}
                            <div class="form-text">{{ form.goods.help_text }}</div>
                        {% endif %}
                        {% if form.goods.errors %}
                            <div class="alert alert-danger mt-2">{{ form.goods.errors }}</div>
                        {% endif %}
                    </div>
                    
                    <div class="mb-3">
                        <label for="{{ form.location.id_for_label }}" class="form-label">{{ form.location.label }}</label>
                        {{ form.location }}
                        {% if form.location.help_text %}
                            <div class="form-text">{{ form.location.help_text }}</div>
                        {% endif %}
                        {% if form.location.errors %}
                            <div class="alert alert-danger mt-2">{{ form.location.errors }}</div>
                        {% endif %}
                    </div>
                    
                    <div class="mb-3">
                        <label for="{{ form.batch_number.id_for_label }}" class="form-label">{{ form.batch_number.label }}</label>
                        {{ form.batch_number }}
                        {% if form.batch_number.help_text %}
                            <div class="form-text">{{ form.batch_number.help_text }}</div>
                        {% endif %}
                        {% if form.batch_number.errors %}
                            <div class="alert alert-danger mt-2">{{ form.batch_number.errors }}</div>
                        {% endif %}
                    </div>
                    
                    <div class="mb-3">
                        <label for="{{ form.actual_quantity.id_for_label }}" class="form-label">{{ form.actual_quantity.label }}</label>
                        {{ form.actual_quantity }}
                        {% if form.actual_quantity.help_text %}
                            <div class="form-text">{{ form.actual_quantity.help_text }}</div>
                        {% endif %}
                        {% if form.actual_quantity.errors %}
                            <div class="alert alert-danger mt-2">{{ form.actual_quantity.errors }}</div>
                        {% endif %}
                    </div>
                    
                    <div class="mb-3">
                        <label for="{{ form.note.id_for_label }}" class="form-label">{{ form.note.label }}</label>
                        {{ form.note }}
                        {% if form.note.help_text %}
                            <div class="form-text">{{ form.note.help_text }}</div>
                        {% endif %}
                        {% if form.note.errors %}
                            <div class="alert alert-danger mt-2">{{ form.note.errors }}</div>
                        {% endif %}
                    </div>
                    
                    <button type="submit" class="btn btn-primary">创建盘点记录</button>
                    <a href="{% url 'warehouse:inventory_list' %}" class="btn btn-secondary">取消</a>
                </form>
            </div>
        </div>
        
        <div class="mt-3">
            <a href="{% url 'warehouse:dashboard' %}" class="btn btn-secondary">返回仪表盘</a>
        </div>
    </div>
</div>
{% endblock %}